﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;

namespace Jn698._45GWTool.Rules
{
    public class MaxLengthValidationRule : ValidationRule
    {
        public int MaxLength { get; set; }

        public override ValidationResult Validate(object value, CultureInfo cultureInfo)
        {
            string text = value as string;
            if (text != null && text.Length > MaxLength)
            {
                return new ValidationResult(false, "输入内容超出最大长度限制。");
            }
            return ValidationResult.ValidResult;
        }
    }
}
